<template>
  <div class="el-toolKit">
    <TableTitle>
      <slot>
        <p>查询条件</p>
      </slot>
    </TableTitle>
    <ConditionSearch style="padding: 5px 0">
      <slot>
        <div class="tableSearch">
          <ul>
            <li>
                <el-input
                    ref="saomaInput"
                    size="mini"
                    v-model="toolCode"
                    placeholder="请输入内容"
                ></el-input>
                <span>工作包器具编码：</span>
            </li>
            <li>
                <el-input
                size="mini"
                v-model="toolName"
                placeholder="请输入内容"
                ></el-input>
                <span>工作包器具名称：</span>
            </li>
            <!-- <li>
                <el-input
                size="mini"
                v-model="length"
                placeholder="请输入内容"
                ></el-input>
                <span>长度：</span>
            </li>
            <li>
                <el-input
                size="mini"
                v-model="width"
                placeholder="请输入内容"
                ></el-input>
                <span>宽度：</span>
            </li>
            <li>
                <el-input
                size="mini"
                v-model="height"
                placeholder="请输入内容"
                ></el-input>
                <span>高度：</span>
            </li>
            <li>
                <el-input
                size="mini"
                v-model="bearWeight"
                placeholder="请输入内容"
                ></el-input>
                <span>重量：</span>
            </li>
            <li>
                <el-input
                size="mini"
                v-model="partCnt"
                placeholder="请输入内容"
                ></el-input>
                <span>最大零件数：</span>
            </li> -->
            <!-- <li>
                <el-input
                size="mini"
                v-model="creationBy"
                placeholder="请输入内容"
                ></el-input>
                <span>创建人：</span>
            </li>
            <li>
                <el-input
                size="mini"
                v-model="creationDate"
                placeholder="请输入内容"
                ></el-input>
                <span>创建时间：</span>
            </li>
            <li>
                <el-input
                size="mini"
                v-model="lastUpdatedBy"
                placeholder="请输入内容"
                ></el-input>
                <span>最后修改人：</span>
            </li>
            <li>
                <el-input
                size="mini"
                v-model="lastUpdateDate"
                placeholder="请输入内容"
                ></el-input>
                <span>最后修改时间：</span>
            </li>
            <li>
                <el-input
                size="mini"
                v-model="lastUpdateIp"
                placeholder="请输入内容"
                ></el-input>
                <span>最后更新IP：</span>
            </li>
            <li>
                <el-input
                size="mini"
                v-model="version"
                placeholder="请输入内容"
                ></el-input>
                <span>版本：</span>
            </li> -->
            <!-- <li style="text-align:right">
                <el-button size="mini" type="primary" @click="searchBtn">查询</el-button>
            </li> -->
          </ul>
          <div class="searchBtnBox">
            <el-button size="mini" type="primary" @click="searchBtn"
                >查询</el-button
              >
          </div>
        </div>
      </slot>
    </ConditionSearch>
    <TableTitle>
      <slot>
        <p>操作按钮</p>
      </slot>
    </TableTitle>
    <TopBtn></TopBtn>
    <TableTitle>
      <slot>
        <p>工作包信息表</p>
      </slot>
    </TableTitle>
    <Table></Table>
  </div>
</template>
<script>
import TopBtn from "./components/TopBtn.vue";
import Table from "./components/InfoTable.vue";
import ConditionSearch from "../aacomponents/ConditionSearch.vue";
import TableTitle from "../../../../components/TableTitle.vue";
import { sysToolKitData } from "@/utils/api.js";
export default {
  name: "ToolKit",
  components: {
    TopBtn,
    Table,
    ConditionSearch,
    TableTitle,
  },
  data() {
    return {
            msWpToolId:'',
            toolCode:'',
            toolName:'',
            length:'',
            width:'',
            height:'',
            bearWeight:'',
            partCnt:'',
            creationBy:'',
            creationDate:'',
            lastUpdatedBy:'',
            lastUpdateDate:'',
            lastUpdateIp:'',
            version:'',
            // 
            pageSize:100,
            pageNumber:1
    };
  },
  methods:{
    // 查询
    searchBtn(){
      sysToolKitData({
        searchParams:{
          // msWpToolId:this.msWpToolId,
          toolCode:this.toolCode,
          toolName:this.toolName,
          length:this.length,
          width:this.width,
          height:this.height,
          bearWeight:this.bearWeight,
          partCnt:this.partCnt
        },
        pageParameter:{
          rows:this.pageSize,
          page:1
        }
      }).then((res)=>{
        if(res.data.retCode == 200){
          this.$Alert({
              title: "成功",
              message: res.data.message,
              type: "success",
          });
          // 查询成功将数据给Table
          this.$bus.$emit('sysTkSxTable',res)
          console.log(res)
        }else {
          this.$bus.$emit('sysTkSxTable',res)
            this.$Alert({
                title: "失败",
                message: res.data.message,
                type: "error",
            });
        }
      })
    }
  },
  mounted(){
    this.$bus.$on('sysTkPageNumber',(e)=>{
      this.pageNumber = e
      sysToolKitData({
        searchParams:{
          // msWpToolId:this.msWpToolId,
          toolCode:this.toolCode,
          toolName:this.toolName,
          length:this.length,
          width:this.width,
          height:this.height,
          bearWeight:this.bearWeight,
          partCnt:this.partCnt
        },
        pageParameter:{
          rows:this.pageSize,
          page:this.pageNumber
        }
      }).then((res)=>{
        if(res.data.retCode == 200){
          this.$Alert({
              title: "成功",
              message: res.data.message,
              type: "success",
          });
          // 查询成功将数据给Table
          this.$bus.$emit('sysTkSxTable',res)
          console.log(res)
        }else {
            this.$Alert({
                title: "失败",
                message: res.data.message,
                type: "error",
            });
        }
      })
    })
    this.$bus.$on('sysTkPageSize',(e)=>{
      this.pageSize = e
      sysToolKitData({
        searchParams:{
          // msWpToolId:this.msWpToolId,
          toolCode:this.toolCode,
          toolName:this.toolName,
          length:this.length,
          width:this.width,
          height:this.height,
          bearWeight:this.bearWeight,
          partCnt:this.partCnt
        },
        pageParameter:{
          rows:this.pageSize,
          page:this.pageNumber
        }
      }).then((res)=>{
        if(res.data.retCode == 200){
          this.$Alert({
              title: "成功",
              message: res.data.message,
              type: "success",
          });
          // 查询成功将数据给Table
          this.$bus.$emit('sysTkSxTable',res)
          console.log(res)
        }else {
            this.$Alert({
                title: "失败",
                message: res.data.message,
                type: "error",
            });
        }
      })
    })
    // 修改刷新Table并定位页数
    this.$bus.$on('sysTkRefreshTable',(e)=>{
      sysToolKitData({
        searchParams:{
          // msWpToolId:this.msWpToolId,
          toolCode:this.toolCode,
          toolName:this.toolName,
          length:this.length,
          width:this.width,
          height:this.height,
          bearWeight:this.bearWeight,
          partCnt:this.partCnt
        },
        pageParameter:{
          rows:this.pageSize,
          page:this.pageNumber
        }
      }).then((res)=>{
        if(res.data.retCode == 200){
          // 查询成功将数据给Table
          this.$bus.$emit('sysTkSxTable',res)
        }
      })
    })
  }
};
</script>
<style scoped>
.tableSearch {
  position: relative;
}
.tableSearch ul{
  overflow: hidden;
}
.tableSearch ul li {
  float: left;
  width: 21%;
  height: 30px;
  line-height: 30px;
  margin-right: 1%;
  margin-bottom: 5px;
  overflow: hidden;

}
.tableSearch ul li span {
  float: right;
}
.tableSearch ul li div {
  float: right;
}
.el-input {
    width: 130px;
}
.searchBtnBox {
  position: absolute;
  top: 0;
  right: 50px;
}
</style>